package org.csc.admin.service;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.csc.admin.config.FooConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;

//@RequestMapping("")
@FeignClient(name = "${service.api}", fallbackFactory = FeignClientFallbackFactory.class)
public interface ApiService {

    String TEST = "api";

    @RequestMapping(TEST)
    String apiTest();


}


@Slf4j
@Component
class FeignClientFallbackFactory implements FallbackFactory<ApiService> {

    @Override
    public ApiService create(Throwable throwable) {
        return new ApiService() {
            @Override
            public String apiTest() {
                log.info("服务异常 -------> {}", throwable.getMessage());
                return "服务异常";
            }
        };
    }
}

